﻿using LS.Entitys;
using LS.Entitys.system;
using System.Collections.Generic;
using System.Data;

namespace LS.Cores
{
    public interface IRepositoryBase<T> where T : class, new()
    {
        /// <summary>
        /// 增加实体
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        long Insert(T model, string dbconstr = null);

     
        /// <summary>
        /// 修改实体
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        int Update(T model, string dbconstr = null);
        /// <summary>
        /// 根据编号获取对象
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        T GetById(long id, string dbconstr = null);

        ///<summary>
        ///删除对象 
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        int Delete(string ids, string dbconstr = null);
        ///<summary>
        ///删除对象 
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        int Recovery(string ids, string dbconstr = null);
        ///<summary>
        ///删除对象 
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        int Remove(string ids, string dbconstr = null);
        /// <summary>
        /// 根据条件返回数据
        /// </summary>
        /// <param name="strwhere"></param>
        /// <returns></returns>
        IList<T> Query(string strwhere, string dbconstr = null);
        /// <summary>
        /// 查列表
        /// </summary>
        /// <param name="sql"></param>
        /// <param name="dbconstr"></param>
        /// <returns></returns>
        DataTable QueryTable(string sql, string dbconstr = null);
        /// <summary>
        /// 查单个值
        /// </summary>
        /// <param name="sql"></param>
        /// <param name="param"></param>
        /// <param name="dbconstr"></param>
        /// <returns></returns>
        object QueryScalar(string sql, object param = null, string dbconstr = null);

        PageDataView<T> GetPageList(string strwhere, int currentPage = 1, int pageSize = 20, string table = null, string fields = "*", string primaryKey = "id", string sort = "id", string dbconstr = null);
    }
}
